<?php
require_once PATH_SITE.'cn/royan/php/proxys/SocketProxy.proxy.php';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once PATH_SITE.'org/puremvc/php/patterns/proxy/Proxy.php';
/**
 * Description of UserConnectProxy
 *
 * @author yanr
 */
class UserConnectProxy extends Proxy
{
    const NAME = "UserConnectProxy";
    protected $socketProxy;

    //put your code here
    public function __construct() {
        parent::__construct( UserConnectProxy::NAME );
        $this->socketProxy = $this->facade->retrieveProxy( SocketProxy::NAME );
    }
    
    public function registerUser( $user )
    {
        $socket = $this->socketProxy->getData();
        $clients = & $socket->__get( "clientInfos" );
        
        $users = array();
        
        FOR( $i = 0; $i < count( $clients ); $i++ )
            IF( isset( $clients[$i] ) )
                array_push( $users, $clients[$i] );
        
        array_push( $users, $user );
        $socket->__set( "clientInfos", $users );
    }
}

?>
